<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
	xmlns:ui="http://java.sun.com/jsf/facelets"
	xmlns:h="http://java.sun.com/jsf/html"
	xmlns:f="http://java.sun.com/jsf/core"
	xmlns:p="http://primefaces.org/ui">

<ui:composition template="/layouts/template.xhtml">
	<ui:define name="body">
		<h:form id="form" acceptcharset="ISO-8859-1">
			<f:metadata>
				<f:viewParam name="param" value="#{productionLaunchBean.param}"/>
			</f:metadata>

			<p:remoteCommand name="launchProgress" ignoreAutoUpdate="true"
				update="panelRegime,panelNormalRegime,panelProductionRegime,panelGratificationRegime,panelGeralRegime,dataTableLaunchProgress,form" />

			<p:panel header="#{msgs['massai.productionLaunch.header.register']}">

				<fieldset>
					<legend><h:outputText value="#{msgs['massai.productionLaunch.dataSpreadsheet']}" /></legend>

					<h:panelGrid columns="4">
						<h:panelGrid>
							<p:outputLabel for="code" value="#{msgs['massai.productionLaunch.code']}" />
							<p:inputText id="code" value="#{productionLaunchBean.completedZerosLeft(productionLaunchBean.spreadsheet.code, 6)}"
								disabled="true" readonly="true" style="text-align: right; width: 60px;" />
						</h:panelGrid>

						<h:panelGrid>
							<p:outputLabel value="#{msgs['massai.productionLaunch.typePayroll']}" for="typePayroll" />
							<p:selectOneMenu required="true" requiredMessage="Tipo da Folha #{msgs['common.required.field']}"
								id="typePayroll" value="#{productionLaunchBean.spreadsheet.typePayroll}" style="width: 160px;" 
								label="#{msgs['massai.productionLaunch.typePayroll']}" tabindex="1" disabled="#{productionLaunchBean.spreadsheet.id ne null}">
								<f:selectItems value="#{productionLaunchBean.typesPayroll}" />
							</p:selectOneMenu>
						</h:panelGrid>

						<h:panelGrid>
							<p:outputLabel value="#{msgs['massai.productionLaunch.accrualBasis']}" for="accrualBasis" />
							<p:inputMask required="true" requiredMessage="Competência #{msgs['common.required.field']}"
								mask="99/9999" id="accrualBasis" converter="accrualBasisConverter" style="width: 90px; text-align: right;"
								value="#{productionLaunchBean.spreadsheet.accrualBasis}" tabindex="2" validator="accrualBasisValidator"
								disabled="#{productionLaunchBean.spreadsheet.id ne null}" readonly="#{productionLaunchBean.spreadsheet.id ne null}" />
						</h:panelGrid>

						<h:panelGrid>
							<p:outputLabel value="#{msgs['massai.productionLaunch.department']}" for="department" />
							<p:selectOneMenu required="true" requiredMessage="Departamento #{msgs['common.required.field']}"
								id="department" value="#{productionLaunchBean.spreadsheet.department}" style="width: 292px;" 
								label="#{msgs['massai.productionLaunch.department']}" tabindex="3" converter="entityConverter"
								disabled="#{productionLaunchBean.spreadsheet.id ne null}">
								<f:selectItems value="#{productionLaunchBean.departmentsByUser}" />
							</p:selectOneMenu>
						</h:panelGrid>
					</h:panelGrid>

					<h:panelGrid>
						<h:outputLabel value="#{msgs['massai.productionLaunch.observation']}" for="observation" />
						<p:inputTextarea
							tabindex="4" id="observation" rows="2" cols="90" autoResize="false" 
							placeholder="#{msgs['massai.productionLaunch.observation']}..."
							value="#{productionLaunchBean.spreadsheet.observation}" 
							disabled="#{productionLaunchBean.spreadsheet.id ne null}" 
							readonly="#{productionLaunchBean.spreadsheet.id ne null}" 
							counter="displayObservation" counterTemplate="{0} caracteres restantes." maxlength="500">
						</p:inputTextarea>
						<h:outputText id="displayObservation" />
					</h:panelGrid>

					<h:panelGrid rendered="#{productionLaunchBean.spreadsheetRevision()}">
						<h:outputLabel style="color: #f00;" value="#{msgs['massai.productionLaunch.observationRevision']}" for="observationRevision" />
						<p:inputTextarea disabled="true" readonly="true"
							id="observationRevision" rows="2" cols="90" autoResize="false" 
							placeholder="#{msgs['massai.productionLaunch.observation']}..."
							value="#{productionLaunchBean.spreadsheet.observationAnalysis}">
						</p:inputTextarea>
					</h:panelGrid>

					<p:spacer height="25px" />

					<h:panelGrid style="width: 100%;">
						<h:panelGrid style="float: right;" columns="2">
							<p:commandButton value="#{msgs['common.back']}" style="padding: 1px !important;"
								action="productionLaunchConsult" ajax="false" immediate="true" tabindex="5"
								onclick="this.form.target='_self'" />

							<h:panelGroup rendered="#{sessionBean.showAction('productionProductionLaunch', 'printout') and productionLaunchBean.spreadsheet.id ne null}">
								<h:form target="_blank">
									<p:commandButton tabindex="6" value="#{msgs['common.printout']}"
										actionListener="#{productionLaunchBean.printout()}" ajax="false" 
										style="margin-right: 5px;"
										onclick="this.form.target='_blank'" />
								</h:form>
							</h:panelGroup>

							<p:commandButton tabindex="6" value="#{msgs['common.save']}"
								actionListener="#{productionLaunchBean.save()}" ajax="false" 
								style="margin-right: 5px;" styleClass="buttonSave" update=":form"
								rendered="#{productionLaunchBean.spreadsheet.id eq null and sessionBean.showAction('productionProductionLaunch', 'insert')}"
								onclick="this.form.target='_self'" />
						</h:panelGrid>
					</h:panelGrid>
				</fieldset>

				<h:panelGroup rendered="#{productionLaunchBean.spreadsheet.id ne null and not productionLaunchBean.spreadsheetPendant()}">
					<p:spacer height="25px" />

					<fieldset>
						<legend><h:outputText value="#{msgs['massai.productionLaunch.dataReleases']}" /></legend>

						<h:panelGrid cellspacing="10" id="checkGrid">
							<h:panelGroup id="checkGroup">
								<p:selectBooleanCheckbox tabindex="1" label="#{msgs['massai.productionLaunch.launchGroup']}" value="#{productionLaunchBean.launchGrouped}">
									<p:ajax event="change" global="false" update="launchSingle,launchGrouped,launchPainel" />
								</p:selectBooleanCheckbox>
								<p:outputLabel value="#{msgs['massai.productionLaunch.launchGroup']}" style="padding: 0 0 3px 10px;" />
							</h:panelGroup>
						</h:panelGrid>

						<p:spacer height="10px" />
						
						<h:panelGrid id="launchPainel">
							<h:panelGrid columns="2">
								<h:panelGroup id="launchSingle" rendered="#{not productionLaunchBean.launchGrouped}">
									<h:panelGrid>
										<p:outputLabel for="employee" value="#{msgs['massai.productionLaunch.employee']}" />
										<p:selectOneMenu id="employee" value="#{productionLaunchBean.entry.employee}" tabindex="7" 
											style="width: 473px;" converter="entityConverter" disabled="#{productionLaunchBean.launching || productionLaunchBean.checkBlockedDepartment()}" 
											filter="true" filterMatchMode="contains">
											<f:selectItems value="#{productionLaunchBean.employeesByDeparment}" />
											<p:ajax event="change" update="panelRegime,panelNormalRegime,panelProductionRegime,panelGratificationRegime,panelGeralRegime" />
										</p:selectOneMenu>
									</h:panelGrid>
								</h:panelGroup>

								<h:panelGroup id="launchGrouped" rendered="#{productionLaunchBean.launchGrouped}" style="width: 100%;">
									<h:panelGrid>
										<p:spacer height="6" />
										<p:commandButton value="#{msgs['massai.productionLaunch.selectedEmployees']}" 
											tabindex="7" onclick="PF('employeeDlg').show();"
											disabled="#{productionLaunchBean.checkBlockedDepartment()}"
											readonly="#{productionLaunchBean.checkBlockedDepartment()}" 
											ajax="true" global="false" immediate="false" process="@this">
										</p:commandButton>
									</h:panelGrid>
								</h:panelGroup>

								<h:panelGrid>
									<p:outputLabel for="regime" value="#{msgs['massai.productionLaunch.regime']}" />
									<p:selectOneMenu id="regime" value="#{productionLaunchBean.entry.regime}" tabindex="8" 
										style="width: 165px;" disabled="#{productionLaunchBean.launching || productionLaunchBean.checkBlockedDepartment()}">
										<f:selectItems value="#{productionLaunchBean.regimes}" />
										<p:ajax event="change" update="panelRegime,panelNormalRegime,panelProductionRegime,panelGratificationRegime,panelGeralRegime" />
									</p:selectOneMenu>
								</h:panelGrid>
							</h:panelGrid>

							<p:spacer height="7px" />

							<h:panelGroup id="panelLaunchGroupedSelected" rendered="#{productionLaunchBean.launchGroupedPainel}">
								<h:panelGrid style="width: 100%;">
								    <ui:repeat var="epg" value="#{productionLaunchBean.selectedEmployees}">
								    	<p><h:outputText value="#{epg.epgCodigo} - #{epg.cargo} - #{epg.nome}" style="width: 100%; font-weight: bold;" /></p>
								    </ui:repeat>
								</h:panelGrid>
							</h:panelGroup>
							
							<p:spacer height="7px" />
						</h:panelGrid>

						<h:panelGroup id="panelRegime">
							<!-- ################################# BLOCO REFERENTE AO REGIME NORMAL -->
							<h:panelGroup id="panelNormalRegime" rendered="#{productionLaunchBean.checkNormalRegime()}">
								<h:panelGrid columns="2">
									<h:panelGrid>
										<p:outputLabel for="normalRegime" value="#{msgs['massai.productionLaunch.service']}" />
										<p:inputText id="normalRegime" style="width: 465px;" readonly="true" disabled="true" 
											value="#{productionLaunchBean.normalArrangements}" />
									</h:panelGrid>

									<h:panelGrid>
										<p:outputLabel for="normalRegimePercentage" value="#{msgs['massai.productionLaunch.percentageValue']}" />
										<p:inputText id="normalRegimePercentage" style="width: 158px; text-align: right;" tabindex="9" 
											value="#{productionLaunchBean.entryItem.valuePercentage}" placeholder="#{msgs['placeholder.percent']}"
											disabled="#{productionLaunchBean.checkBlockedDepartment()}" readonly="#{productionLaunchBean.checkBlockedDepartment()}"
											onkeypress="return numberOnlyCurrency(this, event);">
											<f:convertNumber pattern="#,##0.0000" maxFractionDigits="4" minFractionDigits="4" type="percent" />
											<p:ajax event="change" update="normalRegimePercentage" global="false" />
										</p:inputText>
									</h:panelGrid>
								</h:panelGrid>
							</h:panelGroup>

							<!-- ################################# BLOCO REFERENTE AO REGIME PRODUCAO -->
							<h:panelGroup id="panelProductionRegime" rendered="#{productionLaunchBean.checkProductionRegime()}">
								<h:panelGrid>
									<p:outputLabel for="serviceItem" value="#{msgs['massai.productionLaunch.service']}" />
									<h:panelGroup>
										<p:autoComplete id="serviceItem" value="#{productionLaunchBean.groupItemComplete}"
											completeMethod="#{productionLaunchBean.completeSearchGroupItem}" var="groupItemComplete" 
											itemLabel="#{groupItemComplete.serviceItem.description}" tabindex="10" 
											itemValue="#{groupItemComplete}" label="#{msgs['massai.productionLaunch.service']}" 
											converter="entityConverter" minQueryLength="3" maxResults="20" forceSelection="true" 
											cacheTimeout="30000" autocomplete="true" size="85" emptyMessage="#{msgs['common.no.record.found']}"
											disabled="#{productionLaunchBean.checkBlockedDepartment()}" readonly="#{productionLaunchBean.checkBlockedDepartment()}">
											<p:ajax event="itemSelect" listener="#{productionLaunchBean.onItemSelect}" 
												update="productionRegimeUnitValue,productionRegimeQuantity,productionRegimeTotalValue" />
										</p:autoComplete>

										<h:commandButton value=". . ." 
											style="margin-left: 5px; padding: 2px 8px; cursor: pointer; font-weight: bold; color: #4F4F4F;" 
											type="button" tabindex="6" onclick="PF('groupItemDlg').show();" 
											disabled="#{productionLaunchBean.checkBlockedDepartment()}"
											readonly="#{productionLaunchBean.checkBlockedDepartment()}">
										</h:commandButton>
									</h:panelGroup>
								</h:panelGrid>

								<h:panelGrid columns="3" cellpadding="0" cellspacing="0">
									<h:panelGrid>
										<p:outputLabel for="productionRegimeUnitValue" value="#{msgs['massai.productionLaunch.unitValue']}" />
										<p:inputText id="productionRegimeUnitValue" style="width: 158px; text-align: right;" 
											value="#{productionLaunchBean.groupItemComplete.unitValue}" disabled="true" readonly="true"
											placeholder="#{msgs['placeholder.value']}" label="#{msgs['massai.productionLaunch.unitValue']}">
											<p:ajax event="change" global="false" />
											<f:convertNumber pattern="R$ #,##0.00" maxFractionDigits="2" minFractionDigits="2" type="currency" />
										</p:inputText>
									</h:panelGrid>

									<h:panelGrid>
										<p:outputLabel for="productionRegimeQuantity" value="#{msgs['massai.productionLaunch.quantity']}" />
										<p:inputText id="productionRegimeQuantity" style="width: 158px; text-align: right;" 
											value="#{productionLaunchBean.entryItem.quantity}" tabindex="11" 
											placeholder="#{msgs['placeholder.value']}" label="#{msgs['massai.productionLaunch.quantity']}"
											disabled="#{productionLaunchBean.checkBlockedDepartment()}" readonly="#{productionLaunchBean.checkBlockedDepartment()}"
											onkeypress="return numberOnlyCurrency(this, event);">
											<p:ajax event="change" global="false" listener="#{productionLaunchBean.calculatedTotalValueEntryItem()}" 
												update="productionRegimeQuantity,productionRegimeTotalValue" />
											<f:convertNumber pattern="#,##0.00" maxFractionDigits="2" minFractionDigits="2" type="number" />
										</p:inputText>
									</h:panelGrid>

									<h:panelGrid>
										<p:outputLabel for="productionRegimeTotalValue" value="#{msgs['massai.productionLaunch.totalValue']}" />
										<p:inputText id="productionRegimeTotalValue" style="width: 158px; text-align: right;" 
											value="#{productionLaunchBean.entryItem.totalValue}" disabled="true" readonly="true" 
											placeholder="#{msgs['placeholder.value']}" label="#{msgs['massai.productionLaunch.totalValue']}">
											<p:ajax event="change" global="false" />
											<f:convertNumber pattern="R$ #,##0.00" maxFractionDigits="2" minFractionDigits="2" type="currency" />
										</p:inputText>
									</h:panelGrid>
								</h:panelGrid>
							</h:panelGroup>

							<!-- ################################# BLOCO REFERENTE AO REGIME GRATIFICACAO -->
							<h:panelGroup id="panelGratificationRegime" rendered="#{productionLaunchBean.checkGratificationRegime()}">
								<h:panelGrid>
									<p:outputLabel for="gratificationRegimeTotalGratification" value="#{msgs['massai.productionLaunch.gratificationTotal']}" />
									<p:inputText id="gratificationRegimeTotalGratification" style="width: 158px; text-align: right;" 
										value="#{productionLaunchBean.entry.valueGratification}" tabindex="12" 
										disabled="#{productionLaunchBean.checkBlockedDepartment()}" readonly="#{productionLaunchBean.checkBlockedDepartment()}"
										placeholder="#{msgs['placeholder.value']}" label="#{msgs['massai.productionLaunch.gratificationTotal']}"
										onkeypress="return numberOnlyCurrency(this, event);">
										<p:ajax event="blur" listener="#{productionLaunchBean.calculatedValueLaunchInProgress()}" global="false"
											update="gratificationRegimeTotalGratification,gratificationRegimePercentage,dataTableLaunchProgress" />
										<f:convertNumber pattern="#,##0.00" maxFractionDigits="2" minFractionDigits="2" type="currency" />
									</p:inputText>
								</h:panelGrid>

								<h:panelGrid>
									<p:outputLabel for="gratificationRegimePercentage" value="#{msgs['massai.productionLaunch.percentageValue']}" />
									<p:inputText id="gratificationRegimePercentage" style="width: 158px; text-align: right;" 
										value="#{productionLaunchBean.entryItem.valuePercentage}" tabindex="13" 
										placeholder="#{msgs['placeholder.percent']}" label="#{msgs['massai.productionLaunch.percentageValue']}"
										disabled="#{productionLaunchBean.checkBlockedDepartment()}" readonly="#{productionLaunchBean.checkBlockedDepartment()}"
										onkeypress="return numberOnlyCurrency(this, event);">
										<p:ajax event="change" global="false" update="gratificationRegimePercentage" />
										<f:convertNumber pattern="#,##0.0000" maxFractionDigits="4" minFractionDigits="4" type="percent" />
									</p:inputText>
								</h:panelGrid>
							</h:panelGroup>

							<h:panelGroup id="panelGeralRegime" rendered="#{productionLaunchBean.checkRegime()}">
								<h:panelGrid>
									<h:outputLabel value="#{msgs['massai.productionLaunch.observation']}" for="observationEntry" />
									<p:inputTextarea id="observationEntry" rows="2" cols="90" tabindex="14"
										placeholder="#{msgs['massai.productionLaunch.observation']}..."
										value="#{productionLaunchBean.entryItem.observation}"
										counter="displayItem" counterTemplate="{0} caracteres restantes." maxlength="500"
										disabled="#{productionLaunchBean.checkBlockedDepartment()}" readonly="#{productionLaunchBean.checkBlockedDepartment()}">
									</p:inputTextarea>
									<h:outputText id="displayItem" />
								</h:panelGrid>

								<p:spacer height="5px" />
	
								<h:panelGrid>
									<p:outputLabel for="budgetItem" value="#{msgs['massai.productionLaunch.budgetItem']}" />
									<h:panelGroup>
										<p:autoComplete id="budgetItem" value="#{productionLaunchBean.budgetItemComplete}"
											completeMethod="#{productionLaunchBean.completeSearchBudgetItem}" var="budgetItemComplete"
											itemLabel="#{budgetItemComplete.descriptionComplete}" itemValue="#{budgetItemComplete}"
											label="#{msgs['massai.productionLaunch.budgetItem']}" converter="entityConverter" minQueryLength="3" 
											maxResults="20" forceSelection="true" cacheTimeout="30000" autocomplete="true" size="85" 
											emptyMessage="#{msgs['common.no.record.found']}" tabindex="15"
											disabled="#{productionLaunchBean.checkBlockedDepartment()}" readonly="#{productionLaunchBean.checkBlockedDepartment()}">
											<p:ajax event="itemSelect" listener="#{productionLaunchBean.onItemSelect}" />
										</p:autoComplete>

										<h:commandButton value=". . ." 
											style="margin-left: 5px; padding: 2px 8px; cursor: pointer; font-weight: bold; color: #4F4F4F;" 
											type="button" tabindex="6" onclick="PF('budgetItemDlg').show();" 
											disabled="#{productionLaunchBean.checkBlockedDepartment()}"
											readonly="#{productionLaunchBean.checkBlockedDepartment()}">
										</h:commandButton>
									</h:panelGroup>
								</h:panelGrid>

								<h:panelGrid>
									<p:spacer height="10px" />
									<p:commandButton value="#{msgs['massai.productionLaunch.launch']}" ajax="true" 
										styleClass="buttonNew" actionListener="#{productionLaunchBean.launchEntry()}" tabindex="16"
										update="panelRegime,panelNormalRegime,panelProductionRegime,panelGratificationRegime,panelGeralRegime" 
										oncomplete="launchProgress()" rendered="#{not productionLaunchBean.checkBlockedDepartment()}" />
								</h:panelGrid>
							</h:panelGroup>
						</h:panelGroup>

						<h:panelGroup id="dataTableLaunchProgress" rendered="#{productionLaunchBean.checkLaunchProgress() and not productionLaunchBean.checkBlockedDepartment()}">
							<p:spacer height="20px" />

							<h:panelGrid>
								<h:panelGroup>
									<p:outputLabel for="employeeCode" value="#{msgs['massai.productionLaunch.code']}: " />
									<h:outputText id="employeeCode" value="#{productionLaunchBean.entry.employee.epgCodigo} - #{productionLaunchBean.entry.employee.cargo}" />
								</h:panelGroup>

								<h:panelGroup>
									<p:outputLabel for="employeeName" value="#{msgs['massai.productionLaunch.employee']}: " />
									<h:outputText id="employeeName" value="#{productionLaunchBean.entry.employee.nome}" />
								</h:panelGroup>
							</h:panelGrid>

							<p:dataTable var="item" value="#{productionLaunchBean.itemsLaunchProgress}" rowIndexVar="row">
								<p:column headerText="#{msgs['massai.productionLaunch.service']}">
									<h:outputText value="#{item.groupItem.serviceItem.description}" />
								</p:column>

								<p:column headerText="#{msgs['massai.productionLaunch.unitMeasure']}" width="90">
									<h:outputText value="#{item.groupItem.serviceItem.unitMeasure.acronym} - #{item.groupItem.serviceItem.unitMeasure.nameMeasure}" />
								</p:column>

								<p:column headerText="#{msgs['massai.productionLaunch.unitValue']}" width="90">
									<h:outputText value="#{item.unitPrice}">
										<f:convertNumber pattern="#,##0.00" maxFractionDigits="2" minFractionDigits="2" type="currency" />
									</h:outputText>
								</p:column>

								<p:column headerText="#{msgs['massai.productionLaunch.quantity']}" width="80">
									<h:outputText value="#{item.quantity}">
										<f:convertNumber pattern="#,##0.00" maxFractionDigits="2" minFractionDigits="2" type="number" />
									</h:outputText>
								</p:column>

								<p:column headerText="#{msgs['massai.productionLaunch.totalValue']}" width="90">
									<h:outputText value="#{item.totalValue}">
										<f:convertNumber pattern="#,##0.00" maxFractionDigits="2" minFractionDigits="2" type="currency" />
									</h:outputText>
								</p:column>

								<p:column headerText="#{msgs['massai.productionLaunch.percentageValue']}" width="100">
									<h:outputText value="#{item.valuePercentage}">
										<f:convertNumber pattern="#,##0.0000" maxFractionDigits="4" minFractionDigits="4" type="number" />
									</h:outputText>
								</p:column>

								<p:column headerText="#{msgs['massai.productionLaunch.budgetItem']}" width="110">
									<h:outputText value="#{item.budgetItem.cdReferencia}" />
								</p:column>

								<p:column headerText="#{msgs['massai.productionLaunch.observation']}">
									<h:outputText value="#{item.observation}" />
								</p:column>

								<p:column headerText="#{msgs['common.delete']}" width="42" style="text-align: center;">
									<p:commandLink onclick="if (! window.confirm('Deseja excluir esse registro?') ) {return false}" 
										actionListener="#{productionLaunchBean.deleteEntryItem(item, row)}" update=":form" tabindex="17">
										<img src="#{facesContext.externalContext.requestContextPath}/images/ico_remove.png" 
											width="16" height="16" border="0" name="#{msgs['common.delete']}" 
											title="#{msgs['common.delete']}" alt="#{msgs['common.delete']}" />
									</p:commandLink>
								</p:column>

								<p:columnGroup type="footer">
						            <p:row>
						                <p:column colspan="4" style="text-align:right" footerText="#{msgs['massai.productionLaunch.totals']}" />
						                <p:column footerText="#{productionLaunchBean.decimalFormat('R$ #,##0.00', productionLaunchBean.entry.totalAmount)}" />
						                <p:column style="text-align: left" footerText="#{productionLaunchBean.decimalFormat('#,##0.0000',productionLaunchBean.entry.totalPercentage)} %" />
						                <p:column colspan="3" />
						            </p:row>
						        </p:columnGroup>
							</p:dataTable>

							<p:spacer height="5px" />

							<h:panelGrid width="100%" id="concluirLancamento">
								<p:commandButton ajax="true"
									onclick="if (! window.confirm('Deseja concluir o lançamento?') ) {return false}" 
									value="#{msgs['massai.productionLaunch.finalizeLaunch']}" tabindex="18" 
									actionListener="#{productionLaunchBean.finalizeLaunch()}" update=":form,:employeeForm" 
									styleClass="buttonSave" />
							</h:panelGrid>
						</h:panelGroup>
					</fieldset>
				</h:panelGroup>
				
				<h:panelGroup rendered="#{productionLaunchBean.entriesLaunched.size() ne 0}">
					<p:spacer height="20px" />

					<fieldset>
						<legend><h:outputText value="#{msgs['massai.productionLaunch.releases']}" /></legend>

						<ui:repeat var="entry" value="#{productionLaunchBean.entriesLaunched}">
							<h:panelGroup id="dataTableLaunched">
								<p:spacer height="20px" />

								<h:panelGrid>
									<p:outputLabel value="#{entry.regime.regime}" style="text-transform: uppercase;" />
								
									<h:panelGroup>
										<p:outputLabel value="#{msgs['massai.productionLaunch.code']}: " />
										<h:outputText value="#{entry.employee.epgCodigo} - #{entry.employee.cargo}" />
									</h:panelGroup>

									<h:panelGroup>
										<p:outputLabel value="#{msgs['massai.productionLaunch.employee']}: " />
										<p:commandLink actionListener="#{productionLaunchBean.updateEntry(entry)}" ajax="true" tabindex="19"
											update=":form:panelRegime,:form:panelNormalRegime,:form:panelProductionRegime,:form:panelGratificationRegime,
												:form:panelGeralRegime,:form:launchPainel,:form:launchGrouped,:form:panelLaunchGroupedSelected,:form:checkGrid,:form:checkGroup"
											rendered="#{not productionLaunchBean.spreadsheetPendant()}"
											oncomplete="launchProgress()">
											<p:outputLabel style="color: #25AAE1; cursor: pointer;" value="#{entry.employee.nome}" />
										</p:commandLink>
										<p:outputLabel value="#{entry.employee.nome}" rendered="#{productionLaunchBean.spreadsheetPendant()}" />
									</h:panelGroup>
								</h:panelGrid>

								<p:dataTable var="item" value="#{entry.entryItems}" rowIndexVar="row">
									<p:column headerText="#{msgs['massai.productionLaunch.service']}">
										<h:outputText value="#{item.groupItem.serviceItem.description}" />
									</p:column>

									<p:column headerText="#{msgs['massai.productionLaunch.unitMeasure']}" width="90">
										<h:outputText value="#{item.groupItem.serviceItem.unitMeasure.acronym} - #{item.groupItem.serviceItem.unitMeasure.nameMeasure}" />
									</p:column>

									<p:column headerText="#{msgs['massai.productionLaunch.unitValue']}" width="90">
										<h:outputText value="#{item.unitPrice}">
											<f:convertNumber pattern="#,##0.00" maxFractionDigits="2" minFractionDigits="2" type="currency" />
										</h:outputText>
									</p:column>

									<p:column headerText="#{msgs['massai.productionLaunch.quantity']}" width="80">
										<h:outputText value="#{item.quantity}">
											<f:convertNumber pattern="#,##0.00" maxFractionDigits="2" minFractionDigits="2" type="number" />
										</h:outputText>
									</p:column>

									<p:column headerText="#{msgs['massai.productionLaunch.totalValue']}" width="90">
										<h:outputText value="#{item.totalValue}">
											<f:convertNumber pattern="#,##0.00" maxFractionDigits="2" minFractionDigits="2" type="currency" />
										</h:outputText>
									</p:column>
		
									<p:column headerText="#{msgs['massai.productionLaunch.percentageValue']}" width="100">
										<h:outputText value="#{item.valuePercentage}">
											<f:convertNumber pattern="#,##0.0000" maxFractionDigits="4" minFractionDigits="4" type="number" />
										</h:outputText>
									</p:column>
		
									<p:column headerText="#{msgs['massai.productionLaunch.budgetItem']}" width="110">
										<h:outputText value="#{item.budgetItem.cdReferencia}" />
									</p:column>
		
									<p:column headerText="#{msgs['massai.productionLaunch.observation']}">
										<h:outputText value="#{item.observation}" />
									</p:column>
		
									<p:columnGroup type="footer">
							            <p:row>
							                <p:column colspan="4" style="text-align:right" footerText="#{msgs['massai.productionLaunch.totals']}" />
							                <p:column footerText="#{productionLaunchBean.decimalFormat('R$ #,##0.00', entry.totalAmount)}" />
							                <p:column style="text-align: left" footerText="#{productionLaunchBean.decimalFormat('#,##0.0000', entry.totalPercentage)} %" />
							                <p:column colspan="2" />
							            </p:row>
							        </p:columnGroup>
								</p:dataTable>
							</h:panelGroup>
						</ui:repeat>

						<p:spacer height="15px" />
					</fieldset>
				</h:panelGroup>
			</p:panel>
		</h:form>
		
		<!-- ################################################## MODAIS -->
		<p:dialog header="#{msgs['massai.productionLaunch.modal.header.groupItem']}" 
			id="groupItemDlg" widgetVar="groupItemDlg" resizable="false" modal="true" width="70%" 
			showEffect="fade" appendToBody="true" position="center top" style="margin-top: 10px;"
			closeOnEscape="true">

			<h:form id="groupItemForm" acceptcharset="ISO-8859-1">
				<fieldset>
					<legend><h:outputText value="#{msgs['common.search.filter']}" /></legend>
					
					<h:panelGrid columns="1">
						<h:panelGrid>
							<h:outputLabel value="#{msgs['massai.productionLaunch.modal.description']}" />
							<p:inputText value="#{productionLaunchBean.groupItemModal.serviceItem.description}" 
								style="width: 300px;" />
						</h:panelGrid>

						<h:panelGrid>
							<p:spacer height="5" />
							<p:commandButton value="#{msgs['common.search']}" ajax="true" 
								actionListener="#{productionLaunchBean.findGroupItems()}" 
								update="groupItemForm" />
						</h:panelGrid>
					</h:panelGrid>
				</fieldset>

				<p:dataTable id="tableGroupItem" emptyMessage="#{msgs['common.no.record.found']}" 
					value="#{productionLaunchBean.listGroupItem}" var="item" sortMode="multiple" rows="10" paginator="true"
	                paginatorTemplate="{CurrentPageReport} {FirstPageLink} {PreviousPageLink} {PageLinks} {NextPageLink} {LastPageLink}"
	                currentPageReportTemplate="({currentPage} de {totalPages})" paginatorPosition="bottom" paginatorAlwaysVisible="false">

					<p:column headerText="#{msgs['massai.productionLaunch.modal.level']}" width="70" sortBy="#{item.serviceItem.categoryLevel.code}">
						<h:outputText value="#{item.serviceItem.categoryLevel.code}.#{productionLaunchBean.completedZerosLeft(item.serviceItem.levelService, 3)}" />
					</p:column>

					<p:column headerText="#{msgs['massai.productionLaunch.modal.description']}" sortBy="#{item.serviceItem.description}">
						<h:outputText value="#{item.serviceItem.description}" />
					</p:column>

					<p:column headerText="#{msgs['massai.productionLaunch.unitMeasure']}" sortBy="#{item.serviceItem.unitMeasure.acronym}">
						<h:outputText value="#{item.serviceItem.unitMeasure.acronym} - #{item.serviceItem.unitMeasure.nameMeasure}" />
					</p:column>

					<p:column headerText="#{msgs['massai.productionLaunch.unitValue']}" sortBy="#{item.unitValue}">
						<h:outputText value="#{item.unitValue}">
							<f:convertNumber pattern="#,##0.00" currencySymbol="R$" 
								maxFractionDigits="2" minFractionDigits="2" type="number" />
						</h:outputText>
					</p:column>

					<p:column width="30" style="text-align: center;">
						<p:commandLink actionListener="#{productionLaunchBean.selectedGroupItem(item)}"
								update=":form:serviceItem,:form:productionRegimeUnitValue,:form:productionRegimeQuantity,:form:productionRegimeTotalValue" 
								oncomplete="PF('groupItemDlg').hide();">
							<h:graphicImage value="/images/passed.gif" />
						</p:commandLink>
					</p:column>
				</p:dataTable>
			</h:form>
	    </p:dialog>
	    
	    
	    <p:dialog header="#{msgs['massai.productionLaunch.modal.header.budgetItem']}" 
			id="budgetItemDlg" widgetVar="budgetItemDlg" resizable="false" modal="true" width="70%" 
			showEffect="fade" appendToBody="true" position="center top" style="margin-top: 10px;"
			closeOnEscape="true">

			<h:form id="budgetItemForm" acceptcharset="ISO-8859-1">
				<fieldset>
					<legend><h:outputText value="#{msgs['common.search.filter']}" /></legend>

					<h:panelGrid columns="1">
						<h:panelGrid>
							<h:outputLabel value="#{msgs['massai.productionLaunch.modal.description']}" />
							<p:inputText value="#{productionLaunchBean.budgetItemModal.dePlanilha}" 
								style="width: 300px;" />
						</h:panelGrid>

						<h:panelGrid>
							<p:spacer height="5" />
							<p:commandButton value="#{msgs['common.search']}" ajax="true" 
								actionListener="#{productionLaunchBean.findBudgetItems()}" 
								update="budgetItemForm" />
						</h:panelGrid>
					</h:panelGrid>
				</fieldset>

				<p:dataTable id="tableBudgetItem" emptyMessage="#{msgs['common.no.record.found']}" 
					value="#{productionLaunchBean.listBudgetItem}" var="item" sortMode="multiple" rows="10" paginator="true"
	                paginatorTemplate="{CurrentPageReport} {FirstPageLink} {PreviousPageLink} {PageLinks} {NextPageLink} {LastPageLink}"
	                currentPageReportTemplate="({currentPage} de {totalPages})" paginatorPosition="bottom" paginatorAlwaysVisible="false">

					<p:column headerText="#{msgs['massai.productionLaunch.code']}" width="120" sortBy="#{item.cdReferencia}">
						<h:outputText value="#{item.cdReferencia}" />
					</p:column>

					<p:column headerText="#{msgs['massai.productionLaunch.modal.description']}" sortBy="#{item.dePlanilha}">
						<h:outputText value="#{item.dePlanilha}" />
					</p:column>

					<p:column width="30" style="text-align: center;">
						<p:commandLink rendered="#{item.cdTabela.intValue() > 0}"
							actionListener="#{productionLaunchBean.selectedBudgetItem(item)}"
							update=":form:budgetItem" 
							oncomplete="PF('budgetItemDlg').hide();">
							<h:graphicImage value="/images/passed.gif" />
						</p:commandLink>
					</p:column>
				</p:dataTable>
			</h:form>
	    </p:dialog>
	    
	    
	    <p:dialog header="#{msgs['massai.productionLaunch.modal.header.employee']}" 
			id="employeeDlg" widgetVar="employeeDlg" resizable="false" modal="true" width="70%" 
			showEffect="fade" appendToBody="true" position="center top" style="margin-top: 10px;"
			closeOnEscape="true" onHide="completeHide();" onShow="completeShow();">
			
			<h:form id="employeeForm" acceptcharset="ISO-8859-1">
				<p:remoteCommand name="completeHide" update=":form:launchPainel,:form:panelLaunchGroupedSelected" actionListener="#{productionLaunchBean.completeEmployees()}" />
				<p:remoteCommand name="completeShow" update=":form:launchPainel,employeeForm" actionListener="#{productionLaunchBean.findEmployees()}" />
			
				<fieldset>
					<legend><h:outputText value="#{msgs['common.search.filter']}" /></legend>

					<h:panelGrid columns="1" style="width: 100%;">
						<h:panelGrid>
							<h:outputLabel value="#{msgs['massai.productionLaunch.name']}" />
							<p:inputText value="#{productionLaunchBean.employeeModal.nome}" style="width: 400px;" />
						</h:panelGrid>

						<h:panelGrid columns="2" style="width: 100%;">
							<h:panelGrid>
								<p:spacer height="5" />
								<p:commandButton value="#{msgs['common.search']}" ajax="true" 
									actionListener="#{productionLaunchBean.findEmployees()}" 
									update="employeeForm,tableEmployee" />
							</h:panelGrid>

							<h:panelGrid style="float: right;">
								<p:spacer height="5" />
								<p:commandButton value="#{msgs['common.complete']}" ajax="true" 
									actionListener="#{productionLaunchBean.completeEmployees()}" 
									update="employeeForm,:form:launchPainel,:form:launchGrouped,:form:panelLaunchGroupedSelected"
									oncomplete="PF('employeeDlg').hide();" />
							</h:panelGrid>
						</h:panelGrid>
					</h:panelGrid>
				</fieldset>

				<p:dataTable id="tableEmployee" emptyMessage="#{msgs['common.no.record.found']}" 
					value="#{productionLaunchBean.listEmployees}" var="epg" sortMode="multiple" rows="15" paginator="true"
	                paginatorTemplate="{CurrentPageReport} {FirstPageLink} {PreviousPageLink} {PageLinks} {NextPageLink} {LastPageLink}"
	                currentPageReportTemplate="({currentPage} de {totalPages})" paginatorPosition="bottom" paginatorAlwaysVisible="false"
	                selection="#{productionLaunchBean.selectedEmployees}" rowKey="#{epg.epgCodigo}">
	                
	                <p:column selectionMode="multiple" style="width:16px;text-align:center" />

					<p:column headerText="#{msgs['massai.productionLaunch.code']}" width="120" sortBy="#{epg.epgCodigo}">
						<h:outputText value="#{epg.epgCodigo}" />
					</p:column>

					<p:column headerText="#{msgs['massai.productionLaunch.name']}" sortBy="#{epg.nome}">
						<h:outputText value="#{epg.nome}" />
					</p:column>
					
					<p:column headerText="#{msgs['massai.productionLaunch.function']}" sortBy="#{epg.cargo}">
						<h:outputText value="#{epg.cargo}" />
					</p:column>

					<!-- <p:column headerText="#{msgs['massai.productionGroup.selection']}" width="30" style="text-align: center;">
						<p:selectBooleanCheckbox value="#{epg.selected}">
							<p:ajax event="change" listener="#{productionLaunchBean.selectedEmployeeModal(epg)}" />
						</p:selectBooleanCheckbox>
					</p:column> -->
				</p:dataTable>
			</h:form>
	    </p:dialog>
	</ui:define>
</ui:composition>
</html>